package org.example.seata.bs.auth.handler.code;

import org.example.seata.common.core.util.ApiResp;
import org.example.seata.common.security.constant.AuthTypeConst;
import org.springframework.stereotype.Component;

/**
 * @author hzq
 * @date 2021/12/23 14:28
 */
@Component
public class EmailSendCodeHandler extends AbstractSendCodeHandler {

    @Override
    protected ApiResp<Object> handler(String principal, String handlerType) {

        // 保存验证码到redis
        Code code = saveCodeToRedis(principal, handlerType);

        // todo 使用邮箱服务器发送验证码信息

        return ApiResp.ofSuccess("发送邮箱登录验证码成功", code);
    }

    @Override
    protected boolean supportType(String handlerType) {
        return AuthTypeConst.EMAIL.equals(handlerType);
    }
}
